/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AccesoBaseDatos;



import java.util.logging.Level;
import java.util.logging.Logger;

import java.sql.*;
/**
 *
 * @author a70204
 */
public class ConexionBaseDatos{
   //esta basura es para la conexion de la base de datos
   static String bd = "be";
   static String login = "root";
   static String password ="root";// "root";
   //static String password = "BITACORA";
   private String url = "jdbc:mysql://localhost/"+bd;
   //private Statement stm = null; 
   private Connection conn = null;
   //ActionForward retorno;

    public Connection ConectarBD(){
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            //Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection(url,login,password);//,password
            if (conn != null) {
                System.out.println("Conexión a base de datos "+url+" ... Ok");
            }
        } catch (InstantiationException ex) {
            Logger.getLogger(ConexionBaseDatos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(ConexionBaseDatos.class.getName()).log(Level.SEVERE, null, ex);
        }catch(SQLException ex){
            System.out.println("Hubo un problema al intentar conectarse con la base de datos "+url);
            //retorno = mapping.findForward(FALLACONEXION);
        }catch(ClassNotFoundException ex) {
            System.out.println(ex);
            //retorno = mapping.findForward(FALLACONEXION);
        }
        return conn;    
    }
    
    
    
    
    
}
